package com.adee.netty.codec;

import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.SimpleChannelInboundHandler;

/*
* 说明
* 继承一个HandlerAdapter: ChannelInboundHandlerAdapter
* */
public class NettyServerHandler0 extends SimpleChannelInboundHandler<Object> {
    @Override
    public void channelRead0(ChannelHandlerContext ctx, Object msg) throws Exception {
//        System.out.println("接收到客户端的数据：id=" + msg.getId() + ",name=" + msg.getName());
    }
    /* 数据读取完毕 */
    @Override
    public void channelReadComplete(ChannelHandlerContext ctx) throws Exception {

    }
    /* 处理异常，一般是关闭通道 */
    @Override
    public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception {
        ctx.close();
    }

}
